package cn.edu.nju.software.cdiy.algorithm.performance;
import cn.edu.nju.software.cdiy.bean.*;
import cn.edu.nju.software.cdiy.util.Constant;

public class SoundBoxEvaluator implements Evaluator<SoundBox>{

	@Override
	public double getPerformance(SoundBox t) {
		double score = 0;
		
		//额定功率
		double ratedPower = t.getRatedPower();
		double ratedPowerScore = getRatedPowerBase(ratedPower)*Constant.SB_STD_RATEDPOWER;
//		System.out.println(ratedPowerScore);
		
		//声道
		int soundTunnel = t.getSoundTunnel().getKey();
		double soundTunnelScore = getSoundTunnelBase(soundTunnel)*Constant.SB_STD_SOUNDTUNNEL;
//		System.out.println(soundTunnelScore);
		
		//有源无源
		int activeOrPassive = t.getActiveOrPassive().getKey();
		double activeOrPassiveBase = 0;
		switch(activeOrPassive){
		case 1052:
			activeOrPassiveBase=90;
			break;
		case 1051:
			activeOrPassiveBase=80;
			break;
		}
		double activeOrPassiveScore = activeOrPassiveBase*Constant.SB_STD_ACTIVEORPASSIVE;
//		System.out.println(activeOrPassiveScore);
		
		
		
		
		
		
		score = activeOrPassiveScore+soundTunnelScore+ratedPowerScore;
		return score;
	}

	private double getSoundTunnelBase(int soundTunnel) {
		/*
		 * 声道基础分
		 * 1041  2.0		65
		 * 1042  2.1		70
		 * 1043	 2.2		75
		 * 1044	 2.1+1		80
		 * 1045	 5.1		90
		 * 1046	 单			60
		 * 1047  自选			90
		 * 1048	 4.1		85	
		 * */
		switch(soundTunnel){
		case 1041:
			return 65;
		case 1042:
			return 70;
		case 1043:
			return 75;
		case 1044:
			return 80;
		case 1045:
			return 90;
		case 1046:
			return 60;
		case 1047:
			return 90;
		case 1048:
			return 85;
		default:
			return 80;
		}
	}

	private double getRatedPowerBase(double ratedPower) {
		/*
		 * 额定功率基础分
		 * -10			70
		 * 10-100		80
		 * 100-			90
		 * */
		if(ratedPower<=10)
			return 70;
		else if(ratedPower>10 && ratedPower<=100)
			return 80;
		else return 90;
	}

}
